package cn.lili.modules.operationcenter.entity.dto;

import cn.hutool.core.util.StrUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.operationcenter.entity.dos.OperationCenterWithdrawal;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@ApiModel("运营中心-提现记录dto类")
@Data
public class OperationCenterWithdrawalDTO extends PageVO {

    @ApiModelProperty(value = "运营中心名称")
    private String operationName;

    @ApiModelProperty(value = "运营中心关键字")
    private String keywords;

    @ApiModelProperty(value = "运营中心省份ID")
    private String provinceId;

    @ApiModelProperty(value = "运营中心省份名称")
    private String provinceName;

    @ApiModelProperty(value = "运营中心关联用户表ID")
    private String userId;

    /**
     * @see cn.lili.modules.payment.entity.enums.WithdrawStatusEnum
     */
    @ApiModelProperty(value = "申请状态")
    private String status;

    @ApiModelProperty("开始时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    @ApiModelProperty("结束时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    @ApiModelProperty("运营中心id")
    private String operationId;

    @ApiModelProperty("提现单号")
    private String orderNo;

    private String type;

    /**
     * LambdaQueryWrapper 查询
     * @return
     */
    public LambdaQueryWrapper<OperationCenterWithdrawal> toQueryWapper() {
        LambdaQueryWrapper<OperationCenterWithdrawal> query = new LambdaQueryWrapper<>();
        query.eq(StrUtil.isNotEmpty(operationId),OperationCenterWithdrawal::getOperationId,operationId);
        query.eq(StrUtil.isNotEmpty(userId), OperationCenterWithdrawal::getUserId, userId);
        query.eq(StrUtil.isNotEmpty(operationName), OperationCenterWithdrawal::getOperationName, operationName);
        query.eq(StrUtil.isNotEmpty(status), OperationCenterWithdrawal::getStatus, status);
        query.eq(StrUtil.isNotEmpty(orderNo), OperationCenterWithdrawal::getOrderNo, orderNo);
        if (startTime != null && endTime != null) {
            query.ge(OperationCenterWithdrawal::getCreateTime, startTime);
            query.le(OperationCenterWithdrawal::getCreateTime, endTime);
        }
        query.eq(StrUtil.isNotEmpty(type), OperationCenterWithdrawal::getGreenScoreType, type);
        query.orderByDesc(OperationCenterWithdrawal::getCreateTime).orderByDesc(OperationCenterWithdrawal::getId);
        return query;
    }

}